﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace jnxc.Web.flagship
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtfname.Text.Trim().Length==0)
			{
				strErr+="店名不能为空！\\n";	
			}
			if(this.txtflinker.Text.Trim().Length==0)
			{
				strErr+="联系人不能为空！\\n";	
			}
			if(this.txtfphone.Text.Trim().Length==0)
			{
				strErr+="手机不能为空！\\n";	
			}
			if(this.txtftel.Text.Trim().Length==0)
			{
				strErr+="电话不能为空！\\n";	
			}
			if(this.txtfbrief.Text.Trim().Length==0)
			{
				strErr+="简介不能为空！\\n";	
			}
			if(this.txtfpic.Text.Trim().Length==0)
			{
				strErr+="图片不能为空！\\n";	
			}
			if(this.txtfadd.Text.Trim().Length==0)
			{
				strErr+="地址不能为空！\\n";	
			}
			if(this.txtfprovince.Text.Trim().Length==0)
			{
				strErr+="省不能为空！\\n";	
			}
			if(this.txtfcity.Text.Trim().Length==0)
			{
				strErr+="市不能为空！\\n";	
			}
			if(this.txtfcounty.Text.Trim().Length==0)
			{
				strErr+="县不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtuid.Text))
			{
				strErr+="所有人格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtftime.Text))
			{
				strErr+="开店时间格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string fname=this.txtfname.Text;
			string flinker=this.txtflinker.Text;
			string fphone=this.txtfphone.Text;
			string ftel=this.txtftel.Text;
			string fbrief=this.txtfbrief.Text;
			string fpic=this.txtfpic.Text;
			string fadd=this.txtfadd.Text;
			string fprovince=this.txtfprovince.Text;
			string fcity=this.txtfcity.Text;
			string fcounty=this.txtfcounty.Text;
			int uid=int.Parse(this.txtuid.Text);
			DateTime ftime=DateTime.Parse(this.txtftime.Text);

			jnxc.Model.flagship model=new jnxc.Model.flagship();
			model.fname=fname;
			model.flinker=flinker;
			model.fphone=fphone;
			model.ftel=ftel;
			model.fbrief=fbrief;
			model.fpic=fpic;
			model.fadd=fadd;
			model.fprovince=fprovince;
			model.fcity=fcity;
			model.fcounty=fcounty;
			model.uid=uid;
			model.ftime=ftime;

			jnxc.BLL.flagship bll=new jnxc.BLL.flagship();
			bll.Add(model);
			jnxc.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
